import Rte from 'editor/index'

export function onCaretComposition(editor: Rte) {
  const caret = editor.input.$refs.caret

  caret.addEventListener('compositionstart', function () {
    editor.$data.isComposing = true
  })

  caret.addEventListener('compositionend', function (e) {
    requestAnimationFrame(() => {
      editor.$data.isComposing = false
      editor.input.insertText()
    })
  })
}
